import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;


public class IOTransportClient {
	public static void main(String[] args) throws IOException, InterruptedException {
    	BufferedReader in = new BufferedReader(new FileReader(args[0]));
    	List<String> list = new LinkedList<String>();
    	String data;
    	do {
    		data = in.readLine();
    		list.add(data);
    		
    	} while (data != null);
    	in.close();
        long time = System.currentTimeMillis();
    	Socket serverSocket = new Socket("192.168.1.106", 90);
    	PrintWriter out = new PrintWriter(new OutputStreamWriter(serverSocket.getOutputStream()), true);
    	BufferedReader in1 = new BufferedReader(new InputStreamReader(serverSocket.getInputStream()));
    	Iterator<String> iter = list.iterator();
    	while (iter.hasNext()) {
    		out.println(iter.next());
    	}
    	out.println("end");
    	while (!(in1.readLine().equals("That's all, thank you!"))) {
    		Thread.sleep(5);
    	}
    	in1.close();
    	out.close();
    	serverSocket.close();
    	System.out.println(System.currentTimeMillis() - time);
    }
}
